//
//  purchaseButton.m
//  XYMaterial
//
//  Created by 肖扬 on 16/1/5.
//  Copyright © 2016年 肖扬. All rights reserved.
//

#import "purchaseButton.h"

@implementation purchaseButton
@synthesize tempLab,smallImg,modelId,titleLab;
-(id)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.titleLabel.textColor = UIColorFromRGB(0x9a9a9a);
        self.tempLab = [[UILabel alloc]initWithFrame:CGRectMake(10, (frame.size.height - 20)/2, 85, 20)];
        tempLab.font = [UIFont systemFontOfSize:14];
        [tempLab setBackgroundColor:[UIColor clearColor]];
        [tempLab setTextColor:BLACKColor];
        [self addSubview:tempLab];
        
        self.titleLab = [[UILabel alloc]initWithFrame:CGRectMake(120, (frame.size.height - 20)/2, SWIDTH - 180, 20)];
        titleLab.font = [UIFont systemFontOfSize:14];
        [titleLab setBackgroundColor:[UIColor clearColor]];
        titleLab.text = @"";
        [titleLab setTextColor:GRAYColor];
        [self addSubview:titleLab];
        
        self.smallImg = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 0, 0)];
        [self.smallImg setBackgroundColor:[UIColor clearColor]];
        [self addSubview:self.smallImg];
        
        UIImageView *imageV = [self createImageViewFrame:CGRectMake(SWIDTH - 20, (40 - 12)/2, 7, 12) image:nil imageName:@"引导@2x" tag:0];
        [self addSubview:imageV];
    }
    return self;
}
//创建UIImageView tag值为五位数
- (UIImageView *)createImageViewFrame:(CGRect)frame
                                image:(UIImage *)image
                            imageName:(NSString *)imageName
                                  tag:(NSInteger)tag{
    UIImageView *tempImageView = [[UIImageView alloc]initWithFrame:frame];
    [tempImageView setBackgroundColor:[UIColor clearColor]];
    if (image) {
        tempImageView.image = image;
    }else{
        tempImageView.image = [UIImage imageNamed:imageName];
    }
    [tempImageView setTag:tag];
    return tempImageView;
}
-(void)dealloc{
    self.tempLab = nil;
    self.smallImg = nil;
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
